package com.lalosoft.misgastos.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.lalosoft.misgastos.config.Constants;
import com.lalosoft.misgastos.service.RecalculateService;

public class GastosReceiver extends BroadcastReceiver {
	
	private static String TAG = "GastosReceiver";

	@Override
	public void onReceive(Context context, Intent intent) {
		Bundle bundle = intent.getExtras();
		String action = bundle.getString(Constants.EXTRA_ALARM_MESSAGE);
		try {
			if(action.equals(Constants.EXTRA_ALARM_MESSAGE_ACTION)){
				Log.d(TAG, "BroadcastReceiver onReceive...");
				Intent service = new Intent();
				service.setClass(context, RecalculateService.class);
				context.startService(service);
			}
		} catch (Exception e){
			Log.e(TAG, "Error : " + e.getMessage());
		}
	}

}